package com.study.ju.service.mybatistest;

import com.alibaba.fastjson.JSON;
import com.study.ju.dao.CreateTemplateMapper;
import com.study.ju.model.req.CreateTemplateReq;
import com.study.ju.model.res.CreateTemplateRes;
import com.study.ju.web.TestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MybatistestImpl implements Mybatistest {
    private static final Logger logger = LoggerFactory.getLogger(MybatistestImpl.class);
    @Autowired
    private CreateTemplateMapper createTemplateMapper;

    @Override
    public List<CreateTemplateRes> qryCreateTemplate(CreateTemplateReq req) {
        return createTemplateMapper.qryCreateTemplate(req);
    }

    @Override
    public List<CreateTemplateRes> qryCreateTemplateStr(CreateTemplateReq req) {
        logger.info("getQryStr:" + req.getQryStr());
        return createTemplateMapper.qryCreateTemplateStr(req);
    }

    @Override
    public void update(CreateTemplateReq req) {
        List<CreateTemplateRes> res1 = createTemplateMapper.qryAll();
        logger.info("res1:" + JSON.toJSONString(res1));
        createTemplateMapper.update(req);
        List<CreateTemplateRes> res2 = createTemplateMapper.qryAll();
        logger.info("res2:" + JSON.toJSONString(res2));
    }

    @Override
    public List<CreateTemplateRes> qryAll() {
        List<CreateTemplateRes> res = createTemplateMapper.qryAll();
        logger.info("qryAll:" + JSON.toJSONString(res));
        return res;
    }

    @Override
    public List<CreateTemplateRes> qryAllByCondition(List<String> ids, String para1, String para2) {
        return createTemplateMapper.qryAllByCondition(ids, para1, para2);
    }

    @Override
    public List<CreateTemplateRes> qryParamlist(List<String> strings, CreateTemplateReq req) {
        return createTemplateMapper.qryParamlist(strings,req);
    }
}
